package cn.sunzq.springdata.elasticsearch.demo.document;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Setting;

import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;

/**
 * @创建人 孙中泉
 * @创建时间 2021/7/26
 * @描述
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Document(indexName = "test_demo")
@Setting(refreshInterval = "300s", shards = 1, replicas = 0)
public class DemoDocument {

    @Id
    @Field(type = FieldType.Keyword)
    private String id = UUID.randomUUID().toString();

    @Field(type = FieldType.Keyword)
    private String fieldKeyword;

    @Field(type = FieldType.Integer)
    private Integer fieldInteger;

    @Field(type = FieldType.Long)
    private Long fieldLong;

    @Field(type = FieldType.Float)
    private BigDecimal fieldFloat;

    @Field(type = FieldType.Double)
    private BigDecimal fieldDouble;

    @Field(type = FieldType.Ip)
    private String ip;

    @Field(type = FieldType.Nested)
    private List<String> fieldNested;

    @Field(type = FieldType.Object)
    private List<String> fieldObject;

}
